import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '../views/LoginView.vue'
import NewsView from '../views/NewsView.vue'
import AddNews from '../components/news/AddNews.vue';
import NewsList from '../components/news/NewsList.vue';
import NewsDetail from '../components/news/NewsDetail.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: "/login"
  }, {
    path: '/login',
    name: 'login',
    component: LoginView
  }, {
    path: '/news',
    name: 'news',
    component: NewsView,
    children: [
      {
        path: 'addnews',
        name: 'addnews',
        component: AddNews,
      },
      {
        path: 'newslist',
        name: 'newslist',
        component: NewsList,
      },
      {
        path: 'newsdetail',
        name: 'newsdetail',
        component: NewsDetail,
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
